import axios from 'axios'
import type { Notification } from '../types/notification'

const API_URL = '/api/notifications'

export const notificationService = {
  // 获取用户的所有通知
  async getNotifications(): Promise<Notification[]> {
    const response = await axios.get(API_URL)
    return response.data
  },

  // 标记单个通知为已读
  async markAsRead(notificationId: string): Promise<void> {
    await axios.put(`${API_URL}/${notificationId}/read`)
  },

  // 标记所有通知为已读
  async markAllAsRead(): Promise<void> {
    await axios.put(`${API_URL}/read-all`)
  },

  // 删除通知
  async deleteNotification(notificationId: string): Promise<void> {
    await axios.delete(`${API_URL}/${notificationId}`)
  },

  // 获取未读通知数量
  async getUnreadCount(): Promise<number> {
    const response = await axios.get(`${API_URL}/unread-count`)
    return response.data.count
  },

  // WebSocket 相关方法可以在这里添加
  // 例如：订阅通知、取消订阅等
}